//
//  HDNoNetworkView.swift
//  Excited
//
//  Created by X140Yu on 6/20/16.
//  Copyright © 2016 X140Yu. All rights reserved.
//

import UIKit
import SnapKit

class HDNoNetworkView: UIView {

    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
        UIColor.whiteColor().setFill()
        UIRectFill(rect)
        
        let noNetWorkImageView = UIImageView(image: UIImage(named: "hd-no-network")!)
        let tapGestureRecognizer = UITapGestureRecognizer(target:self, action:#selector(imageTapped))
        noNetWorkImageView.userInteractionEnabled = true
        noNetWorkImageView.addGestureRecognizer(tapGestureRecognizer)
        addSubview(noNetWorkImageView)
        noNetWorkImageView.snp_makeConstraints { (make) in
            make.center.equalTo(0)
        }
        
        let noNetWorkLabel = UILabel()
        noNetWorkLabel.text = "请登录"
        noNetWorkLabel.textColor = UIColor.darkGrayColor()
        noNetWorkLabel.font = UIFont.systemFontOfSize(22)
        addSubview(noNetWorkLabel)
        noNetWorkLabel.snp_makeConstraints { (make) in
            make.top.equalTo(noNetWorkImageView.snp_bottom).offset(8)
            make.centerX.equalTo(0)
        }
    }
    
    func imageTapped() {
        HDLoginViewController.present()
    }

}
